clear
infix nep 2-5 ndays 7-10 type 12-12 onloan 14-22 onlchg2040 24-33 onlchg4160 35-44 onlchg6180 46-55 onlchg81100 57-66 onlchg100120 68-77 avail 79-87 avlchg2140 89-98 avlchg4160 100-109 avlchg6180 111-120 avlchg81100 122-131 avlchg100120 133-142 using "e:\Fis_duration\onloan_avail_over_episode_rep.txt"
log using "E:\FIS_duration\chg_avail_onloan_120days_rep.log"
summarize onloan, detail
summarize onlchg2040 if onlchg2040 > -9
summarize onlchg2040 if onlchg2040 > -9, detail
summarize onlchg4160 if onlchg4160 > -9, detail
summarize onlchg6180 if onlchg6180 > -9, detail
summarize onlchg81100 if onlchg81100 > -9, detail
summarize onlchg100120 if onlchg100120 > -9, detail
gen tot2040 = onloan+onlchg2040
summarize tot2040 if onlchg2040 > -9, detail
gen tot4160 = onloan+onlchg4160
summarize tot4160 if onlchg4160 > -9, detail
gen tot6180 = onloan+onlchg6180
summarize tot6180 if onlchg6180 > -9, detail
gen tot81100 = onloan+onlchg81100
summarize tot81100 if onlchg81100 > -9, detail
gen tot100120 = onloan+onlchg100120
summarize tot100120 if onlchg100120 > -9, detail
summarize tot2040 if onlchg2040 > -9 & type == 1, detail
summarize tot4160 if onlchg4160 > -9 & type == 1, detail
summarize tot6180 if onlchg6180 > -9& type == 1, detail
summarize tot81100 if onlchg81100 > -9 & type == 1, detail
summarize tot100120 if onlchg100120 > -9 & type == 1, detail
summarize tot2040 if onlchg2040 > -9 & type == 2, detail
summarize tot4160 if onlchg4160 > -9 & type == 2, detail
summarize tot6180 if onlchg6180 > -9& type == 2, detail
summarize tot81100 if onlchg81100 > -9 & type == 2, detail
summarize tot100120 if onlchg100120 > -9 & type == 2, detail
summarize tot2040 if onlchg2040 > -9 & type == 3, detail
summarize tot4160 if onlchg4160 > -9 & type == 3, detail
summarize tot6180 if onlchg6180 > -9& type == 3, detail
summarize tot81100 if onlchg81100 > -9 & type == 3, detail
summarize tot100120 if onlchg100120 > -9 & type == 3, detail
summarize onloan if type == 1, detail
summarize onloan if type == 2, detail
summarize onloan if type == 3, detail
gen avl2040 = avail+avlchg2140
summarize avail if avail >= 0
summarize avail if avail >= 0, detail
summarize avl2040 if avail >= 0 & avl2040 > -9, detail
gen avl4160 = avail+avlchg4160
summarize avl4160 if avail >= 0 & avl4160 > -9, detail
gen avl6180 = avail+avlchg6180
summarize avl6180 if avail >= 0 & avl6180 > -8, detail
gen avl81100 = avail+avlchg81100
summarize avl81100 if avail >= 0 & avl81100 > -8, detail
gen avl100120 = avail+avlchg100120
summarize avl100120 if avail >= 0 & avl100120 > -8, detail
summarize avail if avail >= 0 & type == 1, detail
summarize avl2040 if avail >= 0 & avl2040 > -9 & type == 1, detail
summarize avl4160 if avail >= 0 & avl4160 > -9 & type == 1, detail
summarize avl6180 if avail >= 0 & avl6180 > -8 & type == 1, detail
summarize avl81100 if avail >= 0 & avl81100 > -8 & type == 1, detail
summarize avl100120 if avail >= 0 & avl100120 > -8 & type == 1, detail
summarize avail if avail >= 0 & type == 2, detail
summarize avl2040 if avail >= 0 & avl2040 > -9 & type == 2, detail
summarize avl4160 if avail >= 0 & avl4160 > -9 & type == 2, detail
summarize avl6180 if avail >= 0 & avl6180 > -8 & type == 2, detail
summarize avl81100 if avail >= 0 & avl81100 > -8 & type == 2, detail
summarize avl100120 if avail >= 0 & avl100120 > -8 & type == 2, detail
summarize avail if avail >= 0 & type == 3, detail
summarize avl2040 if avail >= 0 & avl2040 > -9 & type == 3, detail
summarize avl4160 if avail >= 0 & avl4160 > -9 & type == 3, detail
summarize avl6180 if avail >= 0 & avl6180 > -8 & type == 3, detail
summarize avl81100 if avail >= 0 & avl81100 > -8 & type == 3, detail
summarize avl100120 if avail >= 0 & avl100120 > -8 & type == 3, detail
log close